package ltd.smallwang.infrastructure.util;

import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;

/**
 * @author justd
 */
public class PasswordUtil {

  private PasswordUtil() {
  }

  private static final Argon2PasswordEncoder ENCODER =
      Argon2PasswordEncoder.defaultsForSpringSecurity_v5_8();

  public static String encode(String password) {
    return ENCODER.encode(password);
  }

  public static boolean matches(String rawPassword, String encodedPassword) {
    return ENCODER.matches(rawPassword, encodedPassword);
  }
}
